package com.ruben.simplescaffold.pojo.common;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 公共实体类
 *
 * @author <achao1441470436@gmail.com>
 * @since 2021/6/23 10:18
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
public abstract class BaseEntity<T extends BaseEntity<T>> extends Model<T> implements Serializable {
    private static final long serialVersionUID = -7675241699344454722L;

    /**
     * 编号
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 创建时间 现在时表主动式创建
     */
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime gmtCreate;

    /**
     * 修改时间 过去分词表被动更新
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime gmtModified;

    /**
     * 逻辑删除 已删除为删除时间，未删除为null
     */
    @TableLogic(delval = "NOW()", value = "'2001-01-01 00:00:00'")
    private LocalDateTime gmtDeleted;

    /**
     * 租户编号
     */
    private Long tenantId;
}
